<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Modules
{
	function  __construct()
	{
		$this->CI =& get_instance();
	}

	function user_module()
	{
		# Load and assign variables from the auth config file
		$this->CI->config->load('auth');
		$auth = $this->CI->config->item('auth');

		foreach($auth as $key => $value)
		{
			$this->$key = $value;
		}

		# Check if the sessions exists with data
		if($this->CI->auth->logged_in())
		{
			$first_name = $this->CI->session->userdata('first_name');
			$module = 'Welcome '.$first_name.'!<br /><a href="'.base_url().'users/profile">Profile</a> | <a href="'.base_url().'users/logout">Logout</a>';
			if($this->CI->auth->admin_logged_in())
			{
				$module .= '<br /><a href="'.base_url().'admin">Control Panel</a>';
			}
		}
		else
		{
			$module = 'You are not logged in<br /><a href="'.base_url().'users/login">Login</a> | <a href="'.base_url().'users/register">Register</a>';
		}
		
		return $module;
	}
}

?>
